package com.ml.loan.common.config;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author Mickey
 * @date $ $
 **/
@Configuration
public class ThreadPoolConfg {

    @Bean("userExecutorService")
    public ExecutorService userExecutorService()  {
        return new ThreadPoolExecutor(
                8,
                50,
                30,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(500),
                new ThreadFactoryBuilder().setNameFormat("user-service-%d").build());
    }
}
